{smcl}
{com}{sf}{ul off}{txt}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\Models, Code, and Papers\HEX Papers\For Journals\HEX Figures\Logfile DoFile.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res} 7 Mar 2025, 00:37:09

{com}. do "C:\Users\CIA\AppData\Local\Temp\STD216c_000000.tmp"
{txt}
{com}. *set trace on
. clear
{txt}
{com}. 
. 
. ****************************************************EXPOSURES
. *import delimited "C:\Users\mflowers\Desktop\Dissertation\HEX Project\Evolving Dataset\Exposure Dataset V1_0.csv"
. import delimited "C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\Exposure Dataset V1_0.csv"
{res}{txt}(encoding automatically selected: ISO-8859-2)
{text}(64 vars, 483 obs)

{com}. 
.         *drop pub_date ex_event ex_type incident target_rep spying_rep sec_rep num_acc spy_nat related
.         drop proquest_article_id reminder pub_date related pub_date a_spy_state b_tar_state
{txt}
{com}.         gen edate = mdy(stmon, stday, styear)
{txt}
{com}.         
.         ds, has(type numeric) 
{txt}{col 1}stmon{col 15}dyad{col 29}n_dyad{col 43}clergy{col 57}motive{col 71}ego{col 85}defection{col 99}min_years{col 113}min_20p{col 127}max_10_20{col 141}edate
{col 1}stday{col 15}dyad_ab{col 29}aid_worker{col 43}other_govt{col 57}govtagent{col 71}num_acc{col 85}traded{col 99}min_z_q{col 113}max_years{col 127}max_20p
{col 1}styear{col 15}dyad_ba{col 29}tourist_ac~c{col 43}diplomat{col 57}money{col 71}released{col 85}expelled{col 99}min_q_5{col 113}max_z_q{col 127}death_sent~e
{col 1}us_spying{col 15}nd_dyad{col 29}business_e~r{col 43}intelligence{col 57}ideology{col 71}convicted{col 85}fined{col 99}min_5_10{col 113}max_q_5{col 127}life_sente~e
{col 1}us_target{col 15}exposure{col 29}journalist{col 43}military{col 57}coercion{col 71}commuted{col 85}payment{col 99}min_10_20{col 113}max_5_10{col 127}add_source4

{com}.         foreach var in `r(varlist)' {c -(} 
{txt}  2{com}.     replace `var' = 0 if `var' == .
{txt}  3{com}.         {c )-}
{txt}(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(307 real changes made)
(298 real changes made)
(296 real changes made)
(302 real changes made)
(289 real changes made)
(296 real changes made)
(280 real changes made)
(285 real changes made)
(270 real changes made)
(337 real changes made)
(337 real changes made)
(337 real changes made)
(337 real changes made)
(337 real changes made)
(337 real changes made)
(2 real changes made)
(93 real changes made)
(93 real changes made)
(93 real changes made)
(93 real changes made)
(93 real changes made)
(93 real changes made)
(93 real changes made)
(93 real changes made)
(93 real changes made)
(93 real changes made)
(93 real changes made)
(93 real changes made)
(93 real changes made)
(93 real changes made)
(93 real changes made)
(93 real changes made)
(93 real changes made)
(93 real changes made)
(93 real changes made)
(93 real changes made)
(93 real changes made)
(93 real changes made)
(0 real changes made)
(0 real changes made)

{com}. 
. 
. *save "C:\Users\mflowers\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_V_FPA.dta", replace
. save "C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive_FPA.dta", replace
{txt}{p 0 4 2}
file {bf}
C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive_FPA.dta{rm}
saved
{p_end}

{com}. clear
{txt}
{com}. 
. use "C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive_FPA.dta", replace
{txt}
{com}. 
. gen work1 = styear
{txt}
{com}. recode work1 (1946/1949 = 1 "1946-49") (1950/1959 = 2 "1950-59") (1960/1969 = 3 "1960-69") (1970/1979 = 4 "1970-79") (1980/1989 = 5 "1980-89") (1990/1999 = 6 "1990-99") (2000/2010 = 7 "2000-10"), gen(decade)
{txt}(483 differences between {bf:work1} and {bf:decade})

{com}. drop work1
{txt}
{com}. 
. 
. ********************************************************************************
. ********************************************************************************
. gen work1 = styear
{txt}
{com}. recode work1 (1946/1962 = 1 "Early Years (1946-62)") (1963/1975 = 2 "Middle Years (1963-1975)") (1976/1991 = 3 "Late Years (1976-1991)") (1992/2000 = 4 "PostCW HM (1992-2000)") (2001/2010 = 5 "PostCW PostHM (2001-2010)"), gen(cold_war)
{txt}(483 differences between {bf:work1} and {bf:cold_war})

{com}. drop work1 
{txt}
{com}. 
. gen work1 = styear
{txt}
{com}. recode work1 (1946/1962 = 1 "1946-62") (1962/2010 = 2 "1963-2010"), gen(early_to_late)
{txt}(483 differences between {bf:work1} and {bf:early_to_late})

{com}. drop work1
{txt}
{com}. 
. gen identity = .
{txt}(483 missing values generated)

{com}. gen identity2 = .
{txt}(483 missing values generated)

{com}. gen identity3 = .
{txt}(483 missing values generated)

{com}. gen identity4 = 666666
{txt}
{com}. gen identity5 = .
{txt}(483 missing values generated)

{com}. replace identity = 88888 if (dyad - 200 < 4000)
{txt}(320 real changes made)

{com}. *replace identity = . if (dyad - 200 > 2800)
. replace identity2 = 99999 if (dyad - 200 > 4100)
{txt}(163 real changes made)

{com}. replace identity3 = 77777 if identity == 88888 | identity2 == 99999
{txt}(483 real changes made)

{com}. *replace identity2 = . if (dyad - 200 < 2800)
. replace identity = 2315 if dyad == 2315
{txt}(64 real changes made)

{com}. replace identity = 2365 if dyad == 2365
{txt}(56 real changes made)

{com}. replace identity = 2290 if dyad == 2290
{txt}(34 real changes made)

{com}. replace identity = 2265 if dyad == 2265
{txt}(33 real changes made)

{com}. replace identity = 2710 if dyad == 2710
{txt}(30 real changes made)

{com}. replace identity = 240 if dyad == 240
{txt}(10 real changes made)

{com}. replace identity = 2310 if dyad == 2310
{txt}(10 real changes made)

{com}. replace identity = 2355 if dyad == 2355
{txt}(10 real changes made)

{com}. replace identity = 2360 if dyad == 2360
{txt}(10 real changes made)

{com}. replace identity = 2630 if dyad == 2630
{txt}(10 real changes made)

{com}. replace identity = 2731 if dyad == 2731
{txt}(8 real changes made)

{com}. replace identity = 2339 if dyad == 2339
{txt}(7 real changes made)

{com}. replace identity = 2645 if dyad == 2645
{txt}(7 real changes made)

{com}. *replace identity = 2345 if dyad == 2345
. replace identity2 = 365002 if dyad == 365002
{txt}(88 real changes made)

{com}. replace identity2 = 265002 if dyad == 265002
{txt}(9 real changes made)

{com}. replace identity2 = 40002 if dyad == 40002
{txt}(8 real changes made)

{com}. replace identity2 = 710002 if dyad == 710002
{txt}(5 real changes made)

{com}. replace identity2 = 290002 if dyad == 290002
{txt}(4 real changes made)

{com}. replace identity2 = 731002 if dyad == 731002
{txt}(4 real changes made)

{com}. 
. replace identity3 = 2315 if dyad == 2315 | dyad == 315002
{txt}(85 real changes made)

{com}. replace identity3 = 2365 if dyad == 2365 | dyad == 365002 
{txt}(144 real changes made)

{com}. replace identity3 = 2290 if dyad == 2290 | dyad == 290002
{txt}(38 real changes made)

{com}. replace identity3 = 2265 if dyad == 2265 | dyad == 265002
{txt}(42 real changes made)

{com}. replace identity3 = 2710 if dyad == 2710 | dyad == 710002
{txt}(35 real changes made)

{com}. replace identity3 = 240 if dyad == 240 | dyad == 40002
{txt}(18 real changes made)

{com}. replace identity3 = 2310 if dyad == 2310 | dyad == 310002
{txt}(11 real changes made)

{com}. replace identity3 = 2355 if dyad == 2355 | dyad == 355002
{txt}(12 real changes made)

{com}. replace identity3 = 2360 if dyad == 2360 | dyad == 360002
{txt}(11 real changes made)

{com}. replace identity3 = 2630 if dyad == 2630 | dyad == 630002
{txt}(10 real changes made)

{com}. replace identity3 = 2731 if dyad == 2731 | dyad == 731002
{txt}(12 real changes made)

{com}. replace identity3 = 2339 if dyad == 2339 | dyad == 339002
{txt}(7 real changes made)

{com}. replace identity3 = 2645 if dyad == 2645 | dyad == 645002
{txt}(9 real changes made)

{com}. *replace identity3 = 2345 if dyad == 2345 | dyad == 345002
. 
. replace identity4 = 2365 if dyad == 2365
{txt}(56 real changes made)

{com}. replace identity4 = 2710 if dyad == 2710
{txt}(30 real changes made)

{com}. replace identity4 = 365710 if dyad == 365002 | dyad == 710002
{txt}(93 real changes made)

{com}. 
. replace identity5 = 2365 if dyad == 2365
{txt}(56 real changes made)

{com}. replace identity5 = 2710 if dyad == 2710
{txt}(30 real changes made)

{com}. replace identity5 = 365710 if dyad > 3002
{txt}(163 real changes made)

{com}. 
. gen num_decade = .
{txt}(483 missing values generated)

{com}. replace num_decade = 1950 if decade == 1
{txt}(37 real changes made)

{com}. replace num_decade = 1960 if decade == 2
{txt}(189 real changes made)

{com}. replace num_decade = 1970 if decade == 3
{txt}(94 real changes made)

{com}. replace num_decade = 1980 if decade == 4
{txt}(33 real changes made)

{com}. replace num_decade = 1990 if decade == 5
{txt}(65 real changes made)

{com}. replace num_decade = 2000 if decade == 6
{txt}(23 real changes made)

{com}. replace num_decade = 2010 if decade == 7
{txt}(42 real changes made)

{com}. 
. bysort num_decade: egen sum_exposure = total(exposure)
{txt}
{com}. 
. bysort num_decade: egen sum_exposure_cze2 = total(exposure) if dyad == 2315 | dyad == 315002
{txt}(398 missing values generated)

{com}. bysort num_decade: egen sum_exposure_rus2 = total(exposure) if dyad == 2365 | dyad == 365002
{txt}(339 missing values generated)

{com}. bysort num_decade: egen sum_exposure_pol2 = total(exposure) if dyad == 2290 | dyad == 290002
{txt}(445 missing values generated)

{com}. bysort num_decade: egen sum_exposure_gdr2 = total(exposure) if dyad == 2265 | dyad == 265002
{txt}(441 missing values generated)

{com}. bysort num_decade: egen sum_exposure_chn2 = total(exposure) if dyad == 2710 | dyad == 710002
{txt}(448 missing values generated)

{com}. 
. gen all_spying = (us_spying + us_target)
{txt}
{com}. bysort styear: egen sum_all_spying = total(all_spying)
{txt}
{com}. bysort styear: egen sum_us_spying = total(us_spying)
{txt}
{com}. bysort styear: egen sum_us_target = total(us_target)
{txt}
{com}. 
. gen work1 = identity
{txt}(163 missing values generated)

{com}. recode work1 (2315 = 1 "Czechoslovakia") (2365 = 2 "Russia") (2290 = 3 "Poland") (2265 = 4 "East Germany") (2710 = 5 "China") (240 = 6 "Cuba") (2310 = 7 "Hungary") (2355 = 8 "Bulgaria") (2360 = 9 "Romania") (2630 = 10 "Iran") (2731 = 11 "North Korea") (2339 = 12 "Albania") (2645 = 13 "Iraq") (88888 = 14 "All Other States"), gen(usa_accused)
{txt}(320 differences between {bf:work1} and {bf:usa_accused})

{com}. drop work1 
{txt}
{com}. 
. gen work1 = identity2
{txt}(320 missing values generated)

{com}. recode work1 (365002 = 1 "Russia") (265002 = 2 "East Germany") (40002 = 3 "Phillipines") (710002 = 4 "China") (29002 = 5 "Poland") (731002 = 6 "North Korea") (99999 = 7 "All Other States"), gen(usa_targeted)
{txt}(159 differences between {bf:work1} and {bf:usa_targeted})

{com}. drop work1 
{txt}
{com}. 
. gen work1 = identity3
{txt}
{com}. recode work1 (2365 = 1 "Russia") (2315 = 2 "Czechoslovakia") (2265 = 3 "East Germany") (2290 = 4 "Poland") (2710 = 5 "China") (240 = 6 "Cuba") (2731 = 7 "North Korea") (2355 = 8 "Bulgaria") (2310 = 9 "Hungary") (2360 = 10 "Romania") (2630 = 11 "Iran") (2645 = 12 "Iraq") (2339 = 13 "Albania") (77777 = 14 "All Other States"), gen(undirected)
{txt}(483 differences between {bf:work1} and {bf:undirected})

{com}. drop work1 
{txt}
{com}. 
. gen work1 = identity4
{txt}
{com}. recode work1 (2365 = 1 "Russia") (2710 = 2 "China") (365710 = 3 "US") (666666 = 4 "All Other States"), gen(rus_chn_us_all)
{txt}(483 differences between {bf:work1} and {bf:rus_chn_us_all})

{com}. drop work1 
{txt}
{com}. 
. gen work1 = identity5
{txt}(234 missing values generated)

{com}. recode work1 (2365 = 1 "Russia") (2710 = 2 "China") (365710 = 3 "US"), gen(rus_chn_us)
{txt}(249 differences between {bf:work1} and {bf:rus_chn_us})

{com}. drop work1 
{txt}
{com}. 
. gen new_identity = 1 if dyad == 2365
{txt}(427 missing values generated)

{com}. replace new_identity = 2 if dyad == 2315
{txt}(64 real changes made)

{com}. replace new_identity = 3 if dyad == 2265
{txt}(33 real changes made)

{com}. replace new_identity = 4 if dyad == 2290
{txt}(34 real changes made)

{com}. replace new_identity = 5 if dyad == 2710
{txt}(30 real changes made)

{com}. replace new_identity = 6 if dyad == 240
{txt}(10 real changes made)

{com}. replace new_identity = 7 if dyad == 2731
{txt}(8 real changes made)

{com}. replace new_identity = 8 if dyad == 2355
{txt}(10 real changes made)

{com}. replace new_identity = 9 if dyad == 2310
{txt}(10 real changes made)

{com}. replace new_identity = 10 if dyad == 2360
{txt}(10 real changes made)

{com}. replace new_identity = 11 if dyad == 2630
{txt}(10 real changes made)

{com}. replace new_identity = 12 if dyad == 2645
{txt}(7 real changes made)

{com}. replace new_identity = 13 if dyad == 2339
{txt}(7 real changes made)

{com}. *replace new_identity = 14 if dyad == 2345
. replace new_identity = 14 if identity3 == 77777
{txt}(49 real changes made)

{com}. 
. ********************************************************************************
. ********************************************************************************
. *This begins Profession TYPE 1
. ********************************************************************************
. ********************************************************************************
. *Recoding various jobs accused spies held when accused so I can group them in descriptive statistics as "Profession"
. gen job = .
{txt}(483 missing values generated)

{com}. replace job = 10 if aid_worker == 1 
{txt}(5 real changes made)

{com}. replace job = 20 if tourist_academic == 1
{txt}(37 real changes made)

{com}. replace job = 30 if business_engineer == 1
{txt}(34 real changes made)

{com}. replace job = 40 if journalist == 1 
{txt}(21 real changes made)

{com}. replace job = 50 if clergy == 1  
{txt}(26 real changes made)

{com}. replace job = 60 if diplomat == 1
{txt}(66 real changes made)

{com}. replace job = 70 if intelligence  == 1
{txt}(59 real changes made)

{com}. replace job = 80 if military == 1
{txt}(77 real changes made)

{com}. replace job = 90 if other_govt == 1
{txt}(21 real changes made)

{com}. 
. gen work1 = job
{txt}(165 missing values generated)

{com}. recode work1 (10 = 1 "Aid Worker") (20 = 2 "Tourist/Academic") (30 = 3 "Business/Engineer") (40 = 4 "Journalist") (50 = 5 "Religious") (60 = 6 "Diplomat") (70 = 7 "Police/Intelligence") (80 = 8 "Current/Former Military") (90 = 9 "Other Government Employee"), gen(profession)
{txt}(318 differences between {bf:work1} and {bf:profession})

{com}. drop work1 
{txt}
{com}. 
. 
. ********************************************************************************
. ********************************************************************************
. *This begins sentencing TYPE 2
. ********************************************************************************
. ********************************************************************************
. 
. *Recoding minimum sentences spies received after alleged exposure
. gen min_yrs = .
{txt}(483 missing values generated)

{com}. replace min_yrs = 60 if released > 0
{txt}(42 real changes made)

{com}. replace min_yrs = 70 if expelled > 0
{txt}(67 real changes made)

{com}. replace min_yrs = 90 if commuted > 0
{txt}(15 real changes made)

{com}. replace min_yrs = 10 if min_years < 6 & min_years > 0.24
{txt}(85 real changes made)

{com}. replace min_yrs = 20 if min_years < 11 & min_years > 5
{txt}(61 real changes made)

{com}. replace min_yrs = 30 if min_years < 16 & min_years > 10
{txt}(35 real changes made)

{com}. replace min_yrs = 40 if min_years < 20 & min_years > 15
{txt}(8 real changes made)

{com}. replace min_yrs = 50 if min_years > 20
{txt}(24 real changes made)

{com}. *replace min_yrs = 100 if min_years < 0.25
. 
. gen work1 = min_yrs
{txt}(175 missing values generated)

{com}. recode work1 (60 = 1 "Released or Acquitted") (70 = 2 "Expelled") (90 = 3 "Commuted or Time Served") (10 = 4 "0.25 to 5") (20 = 5 "6 to 10") (30 = 6 "11 to 15") (40 = 7 "16 to 20") (50 = 8 "> 20"), gen(min_sentence)
{txt}(308 differences between {bf:work1} and {bf:min_sentence})

{com}. drop work1 
{txt}
{com}. 
. 
. ********************************************************************************
. ********************************************************************************
. *Recoding maximum sentences spies received after alleged exposure
. gen max_yrs = .
{txt}(483 missing values generated)

{com}. replace max_yrs = 10 if max_years < 5 & min_years > 0.24
{txt}(34 real changes made)

{com}. replace max_yrs = 20 if max_years < 11 & min_years > 5
{txt}(45 real changes made)

{com}. replace max_yrs = 30 if max_years < 16 & min_years > 10
{txt}(27 real changes made)

{com}. replace max_yrs = 40 if max_years < 20 & min_years > 15
{txt}(6 real changes made)

{com}. replace max_yrs = 50 if max_years > 20
{txt}(44 real changes made)

{com}. replace max_yrs = 60 if life_sentence == 1
{txt}(30 real changes made)

{com}. replace max_yrs = 61 if life_sentence == 2
{txt}(13 real changes made)

{com}. replace max_yrs = 62 if life_sentence == 3
{txt}(6 real changes made)

{com}. replace max_yrs = 63 if life_sentence > 3
{txt}(2 real changes made)

{com}. replace max_yrs = 70 if death_sentence == 1
{txt}(31 real changes made)

{com}. replace max_yrs = 71 if death_sentence == 2
{txt}(14 real changes made)

{com}. replace max_yrs = 72 if death_sentence == 3
{txt}(10 real changes made)

{com}. replace max_yrs = 73 if death_sentence == 4
{txt}(8 real changes made)

{com}. replace max_yrs = 74 if death_sentence == 5
{txt}(1 real change made)

{com}. replace max_yrs = 75 if death_sentence == 6
{txt}(0 real changes made)

{com}. replace max_yrs = 76 if death_sentence == 7
{txt}(2 real changes made)

{com}. replace max_yrs = 77 if death_sentence == 8
{txt}(1 real change made)

{com}. replace max_yrs = 78 if death_sentence == 9
{txt}(0 real changes made)

{com}. replace max_yrs = 79 if death_sentence == 10
{txt}(1 real change made)

{com}. replace max_yrs = 80 if death_sentence > 10
{txt}(5 real changes made)

{com}. *replace max_yrs = 100 if max_years < 0.25
. 
. gen work1 = max_yrs
{txt}(258 missing values generated)

{com}. recode work1 (10 = 1 "0.25 to 5") (20 = 2 "6 to 10") (30 = 3 "11 to 15") (40 = 4 "16 to 20") (50 = 5 "> 20") (60/63 = 6 "Life") (70/80 = 7 "Death"), gen(max_sentence)
{txt}(225 differences between {bf:work1} and {bf:max_sentence})

{com}. drop work1 
{txt}
{com}. 
. gen maxmin = .
{txt}(483 missing values generated)

{com}. replace maxmin = 10 if released > 0
{txt}(42 real changes made)

{com}. replace maxmin = 11 if commuted > 0
{txt}(15 real changes made)

{com}. replace maxmin = 20 if expelled > 0
{txt}(67 real changes made)

{com}. replace maxmin = 30 if life_sentence > 0
{txt}(51 real changes made)

{com}. replace maxmin = 40 if death_sentence > 0
{txt}(73 real changes made)

{com}. 
. gen work1 = maxmin
{txt}(264 missing values generated)

{com}. recode work1 (10/11 = 1 "Released") (20 = 2 "Expelled") (30 = 3 "Life Sentence") (40 = 4 "Death Sentence"), gen(min_to_max)
{txt}(219 differences between {bf:work1} and {bf:min_to_max})

{com}. drop work1
{txt}
{com}. 
. gen lifedeath = .
{txt}(483 missing values generated)

{com}. replace lifedeath = 10 if life_sentence > 0
{txt}(51 real changes made)

{com}. replace lifedeath = 20 if death_sentence > 0
{txt}(73 real changes made)

{com}. 
. gen work1 = lifedeath
{txt}(375 missing values generated)

{com}. recode work1 (10 = 1 "Life Sentence") (20 = 2 "Death Sentence"), gen(life_to_death)
{txt}(108 differences between {bf:work1} and {bf:life_to_death})

{com}. drop work1
{txt}
{com}. 
. ********************************************************************************
. ********************************************************************************
. *This begins other miscelaneous information TYPE 3
. ********************************************************************************
. *Motive, Defection, Trade, Fines, Number Accused
. ********************************************************************************
. gen motivation = .
{txt}(483 missing values generated)

{com}. replace motivation = 10 if motive == 1
{txt}(65 real changes made)

{com}. replace motivation = 20 if motive == 2
{txt}(59 real changes made)

{com}. replace motivation = 30 if motive == 3
{txt}(11 real changes made)

{com}. replace motivation = 40 if motive == 4
{txt}(9 real changes made)

{com}. replace motivation = 50 if motive == 5
{txt}(2 real changes made)

{com}. *replace motivation = 60 if motive < 1
. *replace motivation = 60 if motive > 5
. 
. gen work1 = motivation
{txt}(337 missing values generated)

{com}. recode work1 (10 = 1 "State Agent") (20 = 2 "Money") (30 = 3 "Ideology") (40 = 4 "Coercion/Compromise") (50 = 5 "Ego/Excitement"), gen(reason)
{txt}(146 differences between {bf:work1} and {bf:reason})

{com}. drop work1
{txt}
{com}. 
. ********************************************************************************
. ********************************************************************************
. *This Section begins graphing and labeling
. ********************************************************************************
. ********************************************************************************
. 
. *us_spying is when US was caught spying
. *us_target is when US caught others spying against it
. label variable released "Released"
{txt}
{com}. label variable profession "Profession"
{txt}
{com}. label variable min_sentence "Minimum Sentence in Years"
{txt}
{com}. label variable max_sentence "Maximum Sentence in Years"
{txt}
{com}. label variable decade "Decade"
{txt}
{com}. label variable cold_war "Cold War"
{txt}
{com}. label variable exposure "Exposure"
{txt}
{com}. label variable n_dyad "Nuclear Dyad"
{txt}
{com}. label variable us_spying "State Exposed"
{txt}
{com}. label variable us_target "US is Target"
{txt}
{com}. label variable traded "Alleged Spies Traded"
{txt}
{com}. label variable defection "Defection"
{txt}
{com}. label variable expelled "Expelled"
{txt}
{com}. label variable released "Released"
{txt}
{com}. label variable fined "Fined"
{txt}
{com}. label variable payment "Amount of Fine"
{txt}
{com}. label variable reason "Motivation of Accused"
{txt}
{com}. label variable traded "Traded"
{txt}
{com}. label variable usa_accused "US Exposed"
{txt}
{com}. label variable usa_targeted "Foreign State Exposed"
{txt}
{com}. label variable undirected "States"
{txt}
{com}. 
. label define yesno 0 "No" 1 "Yes", replace
{txt}
{com}. 
. label define n_dyad 0 "No" 1 "Yes", replace
{txt}
{com}. label values n_dyad n_dyad
{txt}
{com}. 
. label define exposure 0 "No" 1 "Yes", replace
{txt}
{com}. label values exposure exposure
{txt}
{com}. 
. label define us_target 0 "United States" 1 "Foreign State", replace
{txt}
{com}. label values us_target us_target
{txt}
{com}. label define us_spying 0 "Foreign State" 1 "United States", replace
{txt}
{com}. label values us_spying us_spying
{txt}
{com}. 
. label variable all_spying "All Exposures"
{txt}
{com}. label define all_spying 0 "No" 1 "Yes", replace 
{txt}
{com}. label values all_spying all_spying
{txt}
{com}. 
. label variable us_spying "US is Offender"
{txt}
{com}. label define us_spying 0 "No" 1 "Yes", replace 
{txt}
{com}. label values us_spying us_spying
{txt}
{com}. 
. label variable us_target "US is Target"
{txt}
{com}. label define us_target 0 "No" 1 "Yes", replace 
{txt}
{com}. label values us_target us_target
{txt}
{com}. 
. gen tot_spying = all_spying if all_spying == 1
{txt}
{com}. label variable tot_spying "All Exposures"
{txt}
{com}. label define tot_spying 0 "No" 1 "Yes", replace 
{txt}
{com}. label values tot_spying tot_spying
{txt}
{com}. 
. gen us_is_spying = us_spying if us_spying == 1
{txt}(164 missing values generated)

{com}. label variable us_is_spying "US is Offender"
{txt}
{com}. label define us_is_spying 0 "No" 1 "Yes", replace 
{txt}
{com}. label values us_is_spying us_is_spying
{txt}
{com}. 
. gen us_is_target = us_target if us_target == 1
{txt}(319 missing values generated)

{com}. label variable us_is_target "US is Target"
{txt}
{com}. label define us_is_target 0 "No" 1 "Yes", replace 
{txt}
{com}. label values us_is_target us_is_target
{txt}
{com}. 
. 
. *save "C:\Users\mflowers\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive.dta", replace
. save "C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive_FPA.dta", replace
{txt}{p 0 4 2}
file {bf}
C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive_FPA.dta{rm}
saved
{p_end}

{com}. clear
{txt}
{com}. 
. clear
{txt}
{com}. use "C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive_FPA.dta"
{txt}
{com}. save "C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive_FPA2.dta", replace
{txt}{p 0 4 2}
file {bf}
C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive_FPA2.dta{rm}
saved
{p_end}

{com}. clear
{txt}
{com}. 
. ******************************************************************************
. *FIGURE 1 Creation and Export
. *Total Exposures between 1946-2010, Manually Labeled across 3 periods - Early/Mid-Late/Post
. clear
{txt}
{com}. use "C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive_FPA2.dta", replace
{txt}
{com}. 
. tsset dyad edate, daily
{res}
{col 1}{txt:Panel variable: }{res:dyad}{txt: (unbalanced)}
{p 1 16 2}{txt:Time variable: }{res:edate}{txt:, }{res:{bind:28mar1946}}{txt: to }{res:{bind:18jul2010}}{txt:, but with gaps}{p_end}
{txt}{col 10}Delta: {res}1 day
{txt}
{com}. 
. *Fill in gaps
. tsfill
{txt}
{com}. quietly replace edate = mdy(stmon,stday,styear) if edate == .
{txt}
{com}. scalar ref_1950 = mdy(1,1,1950)
{txt}
{com}. scalar ref_1960 = mdy(1,1,1960)
{txt}
{com}. scalar ref_1963 = mdy(1,1,1963)
{txt}
{com}. scalar ref_1970 = mdy(1,1,1970)
{txt}
{com}. scalar ref_1980 = mdy(1,1,1980)
{txt}
{com}. scalar ref_1990 = mdy(1,1,1990)
{txt}
{com}. scalar ref_1991 = mdy(1,1,1991)
{txt}
{com}. scalar ref_2000 = mdy(1,1,2000)
{txt}
{com}. scalar ref_2010 = mdy(1,1,2010)
{txt}
{com}. 
. tssmooth ma sum_all_spying_ma111 = sum_all_spying, window(1 1 1)
{txt}The smoother applied was
{res}{p 5 5 5} by dyad : (1/3)*[x(t-1) + 1*x(t) + x(t+1)]; x(t)= sum_all_spying{p_end}
{txt}Note: Missing values are given a weight of zero in the smoother.

{com}. 
. twoway ///
>     (tsline sum_all_spying sum_all_spying_ma, lpattern(solid)), xline(`=ref_1963', lpattern(solid) lcolor(black)) xline(`=ref_1991', lpattern(solid) lcolor(black)) title("Figure 1: Exposures 1946-2010") ytitle("Frequency of Exposures") xtitle("Year") xlabel(`=ref_1950' "1950" `=ref_1960' "1960" `=ref_1970' "1970" `=ref_1980' "1980" `=ref_1990' "1990" `=ref_2000' "2000" `=ref_2010' "2010", labsize(small)) yscale(range(0 30)) ylabel(0(5)30, labsize(small)) legend(off) scheme(s1mono) aspect(.4)
{res}{txt}
{com}. 
. clear
{txt}
{com}. 
. ******************************************************************************
. *FIGURE 2 Creation and Export
. clear
{txt}
{com}. use "C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive_FPA.dta"
{txt}
{com}. save "C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive_FPA2.dta", replace
{txt}{p 0 4 2}
file {bf}
C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive_FPA2.dta{rm}
saved
{p_end}

{com}. clear
{txt}
{com}. use "C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive_FPA2.dta", replace
{txt}
{com}. graph hbar (count) us_is_spying us_is_target, over(undirected, sort(new_identity) reverse descending) legend(off) title("Figure 2: Exposure Count by State, 1946-2010") scheme(s1mono) blabel(bar, format(%9.0g)) yscale(range(0 100)) ylabel(0(10)100) legend(on order(2 "US is Target" 1 "US is Offender") position(4) ring(0) cols(1) region(lstyle(none)))
{res}{txt}
{com}. graph export "C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\Models, Code, and Papers\HEX Papers\Graphs and Tables\Figure2_FPA.png", width(1200) replace
{txt}{p 0 4 2}
file {bf}
C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\Models, Code, and Papers\HEX Papers\Graphs and Tables\Figure2_FPA.png{rm}
saved as
PNG
format
{p_end}

{com}. 
. clear
{txt}
{com}. 
. ******************************************************************************
. *FIGURE 3 Creation and Export
. clear
{txt}
{com}. use "C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive_FPA.dta"
{txt}
{com}. save "C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive_FPA2.dta", replace
{txt}{p 0 4 2}
file {bf}
C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive_FPA2.dta{rm}
saved
{p_end}

{com}. clear
{txt}
{com}. use "C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive_FPA2.dta", replace
{txt}
{com}. graph hbar (count) us_is_spying us_is_target, over(reason, reverse descending) legend(off) title("Figure 3: Motivation of Accused (MICE)") scheme(s1mono) blabel(bar, format(%9.0g)) yscale(range(0 50)) ylabel(0(10)50) legend(on order(2 "US is Target" 1 "US is Offender") position(4) ring(0) cols(1) region(lstyle(none)))
{res}{txt}
{com}. graph export "C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\Models, Code, and Papers\HEX Papers\Graphs and Tables\Figure3_FPA.png", width(1200) replace
{txt}{p 0 4 2}
file {bf}
C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\Models, Code, and Papers\HEX Papers\Graphs and Tables\Figure3_FPA.png{rm}
saved as
PNG
format
{p_end}

{com}. 
. clear
{txt}
{com}. 
. ******************************************************************************
. *FIGURE 4 Creation and Export
. clear
{txt}
{com}. use "C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive_FPA.dta"
{txt}
{com}. save "C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive_FPA2.dta", replace
{txt}{p 0 4 2}
file {bf}
C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive_FPA2.dta{rm}
saved
{p_end}

{com}. clear
{txt}
{com}. use "C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive_FPA2.dta", replace
{txt}
{com}. 
. gen profession_order = .
{txt}(483 missing values generated)

{com}.         replace profession_order = 1 if profession == 9   // Other Government Employee (TOP)
{txt}(21 real changes made)

{com}.         replace profession_order = 2 if profession == 1   // Aid Worker
{txt}(4 real changes made)

{com}.         replace profession_order = 3 if profession == 4   // Journalist
{txt}(20 real changes made)

{com}.         replace profession_order = 4 if profession == 5   // Religious
{txt}(24 real changes made)

{com}.         replace profession_order = 5 if profession == 3   // Business/Engineer
{txt}(26 real changes made)

{com}.         replace profession_order = 6 if profession == 2   // Tourist/Academic
{txt}(31 real changes made)

{com}.         replace profession_order = 7 if profession == 7   // Police/Intelligence
{txt}(56 real changes made)

{com}.         replace profession_order = 8 if profession == 6   // Diplomat
{txt}(61 real changes made)

{com}.         replace profession_order = 9 if profession == 8   // Current/Former Military (BOTTOM)
{txt}(75 real changes made)

{com}. 
. graph hbar (count) tot_spying, over(profession, sort(profession_order) label(labsize(small) notick) gap(50)) title("Figure 4: Frequency of Exposures by Profession") scheme(s1mono) blabel(bar, format(%9.0g)) yscale(range(0 80)) ylabel(0(10)80, grid gstyle(dash)) ytitle("")
{res}{p 0 4 2}
{txt}(note:  named style
dash not found in class
gridstyle,  default attributes used)
{p_end}
{res}{txt}
{com}. graph export "C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\Models, Code, and Papers\HEX Papers\Graphs and Tables\Figure4_FPA.png", width(1200) replace
{txt}{p 0 4 2}
file {bf}
C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\Models, Code, and Papers\HEX Papers\Graphs and Tables\Figure4_FPA.png{rm}
saved as
PNG
format
{p_end}

{com}. 
. clear
{txt}
{com}. 
. ******************************************************************************
. *FIGURE 5 Creation and Export NOT YET WORKING
. clear
{txt}
{com}. use "C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive_FPA.dta"
{txt}
{com}. save "C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive_FPA2.dta", replace
{txt}{p 0 4 2}
file {bf}
C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive_FPA2.dta{rm}
saved
{p_end}

{com}. clear
{txt}
{com}. use "C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive_FPA2.dta", replace
{txt}
{com}. 
. gen sortby = .
{txt}(483 missing values generated)

{com}.         replace sortby = 1 if identity5 == 365710
{txt}(163 real changes made)

{com}.         replace sortby = 2 if identity5 == 2365
{txt}(56 real changes made)

{com}.         replace sortby = 3 if identity5 == 2710
{txt}(30 real changes made)

{com}. 
. graph bar other_govt journalist clergy business_engineer tourist_academic intelligence diplomat military, ///
>     over(rus_chn_us, sort(sortby) reverse descending) percent ///
>     bar(8, color(black)) ///
>     bar(7, color(gs3)) ///
>     bar(6, color(gs5)) ///
>     bar(5, color(gs7)) ///
>     bar(4, color(gs9)) ///
>     bar(3, color(gs11)) ///
>     bar(2, color(gs13)) ///
>     bar(1, color(gs10)) ///
>     ylabel(none) ytitle("") ///
>     legend(order(8 "Current / Former Military" 7 "Tourist / Academic" 6 "Journalist" ///
>                  5 "Diplomat" 4 "Business / Engineer" 3 "Other Government" ///
>                  2 "Police / Intelligence" 1 "Religious") ///
>            ring(0) position(12) col(3) colgap(1) size(small) symxsize(2) symysize(2) ///
>            region(lcolor(none) lwidth(none) color(none))) /// Transparent background, reduced column spacing
>     title("Figure 5: Percent Exposures by Profession" ///
>           "for Target States US, Russia, & China", size(large)) ///
>     b1title(" ") /// Creates whitespace below the title for the legend
>     scheme(s1mono) ///
>     blabel(bar, format(%9.1f) position(outside) size(vsmall) angle(90)) ///
>     graphregion(margin(large) color(white)) /// Adds whitespace above the graph
>     plotregion(style(none))
{res}{txt}
{com}. 
. 
. *military diplomat intelligence tourist_academic business_engineer clergy journalist other_govt
. *other_govt journalist clergy business_engineer tourist_academic intelligence diplomat military
. graph export "C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\Models, Code, and Papers\HEX Papers\Graphs and Tables\Figure5_FPA.png", width(1200) replace
{txt}{p 0 4 2}
file {bf}
C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\Models, Code, and Papers\HEX Papers\Graphs and Tables\Figure5_FPA.png{rm}
saved as
PNG
format
{p_end}

{com}. 
. clear
{txt}
{com}. 
. ******************************************************************************
. *FIGURE 6 Creation and Export
. clear
{txt}
{com}. use "C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive_FPA.dta"
{txt}
{com}. save "C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive_FPA2.dta", replace
{txt}{p 0 4 2}
file {bf}
C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive_FPA2.dta{rm}
saved
{p_end}

{com}. clear
{txt}
{com}. use "C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\exposures_descriptive_FPA2.dta", replace
{txt}
{com}. 
. label define usa_labels 99 "United States", modify
{txt}
{com}. replace usa_accused = 99 if us_target == 1  // Assign a unique number to US
{txt}(164 real changes made)

{com}. label values usa_accused usa_labels  // Apply the label
{txt}
{com}. 
. gen usa_accused_order = .
{txt}(483 missing values generated)

{com}. replace usa_accused_order = 1 if usa_accused == 99  // United States
{txt}(164 real changes made)

{com}. replace usa_accused_order = 2 if usa_accused == 2   // Russia
{txt}(55 real changes made)

{com}. replace usa_accused_order = 3 if usa_accused == 1   // Czechoslovakia
{txt}(64 real changes made)

{com}. replace usa_accused_order = 4 if usa_accused == 4   // East Germany
{txt}(33 real changes made)

{com}. replace usa_accused_order = 5 if usa_accused == 5   // China
{txt}(30 real changes made)

{com}. replace usa_accused_order = 6 if usa_accused == 3   // Poland
{txt}(34 real changes made)

{com}. replace usa_accused_order = 7 if usa_accused == 11  // North Korea
{txt}(8 real changes made)

{com}. replace usa_accused_order = 8 if usa_accused == 9   // Romania
{txt}(10 real changes made)

{com}. replace usa_accused_order = 9 if usa_accused == 13  // Iraq
{txt}(7 real changes made)

{com}. replace usa_accused_order = 10 if usa_accused == 6  // Cuba
{txt}(10 real changes made)

{com}. replace usa_accused_order = 11 if usa_accused == 8  // Bulgaria
{txt}(10 real changes made)

{com}. replace usa_accused_order = 12 if usa_accused == 7  // Hungary
{txt}(10 real changes made)

{com}. replace usa_accused_order = 13 if usa_accused == 12 // Albania
{txt}(7 real changes made)

{com}. replace usa_accused_order = 14 if usa_accused == 10 // Iran
{txt}(10 real changes made)

{com}. replace usa_accused_order = 15 if usa_accused == 14 // All Other States
{txt}(31 real changes made)

{com}. 
. label define usa_accused_order_labels ///
>     1 "United States" ///
>     2 "Russia" ///
>     3 "Czechoslovakia" ///
>     4 "East Germany" ///
>     5 "China" ///
>     6 "Poland" ///
>     7 "North Korea" ///
>     8 "Romania" ///
>     9 "Iraq" ///
>     10 "Cuba" ///
>     11 "Bulgaria" ///
>     12 "Hungary" ///
>     13 "Albania" ///
>     14 "Iran" ///
>     15 "All Other States"
{txt}
{com}. 
. label values usa_accused_order usa_accused_order_labels
{txt}
{com}. gen usa_accused_sort = usa_accused_order
{txt}
{com}. 
. gen has_death = 1 if (death_sentence > 0)
{txt}(410 missing values generated)

{com}. gen has_life = 1 if (life_sentence > 0)
{txt}(432 missing values generated)

{com}. gen has_expelled = 1 if (expelled > 0)
{txt}(416 missing values generated)

{com}. gen has_released = 1 if (released > 0)
{txt}(441 missing values generated)

{com}. 
. graph hbar (sum) has_death has_life has_expelled has_released, over(usa_accused_order, sort(usa_accused_sort) reverse descending) legend(on order(4 "Released/Acquittal" 3 "Expulsion" 2 "Life" 1 "Death") position(4) ring(0) cols(1) region(lstyle(none))) bar(1, color(black)) bar(2, color(gs6)) bar(3, color(gs10)) bar(4, color(gs14)) title("Figure 6: Frequency of Exposures that Include a Sentence of Death, Life, Expulsion, or Release") scheme(s1mono) yscale(range(0 25)) ylabel(0(5)25)
{res}{txt}
{com}. 
.             
. graph export "C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\Models, Code, and Papers\HEX Papers\Graphs and Tables\Figure6_FPA.png", width(1200) replace
{txt}{p 0 4 2}
file {bf}
C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\Models, Code, and Papers\HEX Papers\Graphs and Tables\Figure6_FPA.png{rm}
saved as
PNG
format
{p_end}

{com}. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
{txt}end of do-file

{com}. log close
      {txt}name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\CIA\Desktop\Dissertation\HEX Project\Evolving Dataset\Models, Code, and Papers\HEX Papers\For Journals\HEX Figures\Logfile DoFile.smcl
  {txt}log type:  {res}smcl
 {txt}closed on:  {res} 7 Mar 2025, 00:37:41
{txt}{.-}
{smcl}
{txt}{sf}{ul off}